package com.JobFind.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

import com.JobFind.DTO.UserDTO;


/**
 * TbUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="tb_user",catalog="jobfind")
@Proxy(lazy = false)
public class TbUser  implements java.io.Serializable {


    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
     private Integer userId;
     private TbCompany tbCompany;
     private String userCode;
     private String userLoginName;
     private String userPwd;
     private String userNickName;
     private Integer userSex;
     private String userNation;
     private String homePlace;
     private String userBirthday;
     private String userPolitics;
     private String userSchool;
     private String userMajor;
     private String userEnglish;
     private String userPhone;
     private String userEmail;
     private String userQq;
     private String userAddress;
     private String userPhoto;
     private String userRemarks;
     private Set<TbLog> tbLogs = new HashSet<TbLog>(0);
     private Set<TbResume> tbResumes = new HashSet<TbResume>(0);


    // Constructors

    /** default constructor */
    public TbUser() {
    }

	/** minimal constructor */
    public TbUser(String userLoginName, String userPwd) {
        this.userLoginName = userLoginName;
        this.userPwd = userPwd;
    }
    
    /** full constructor */
    public TbUser(TbCompany tbCompany, String userCode, String userLoginName, String userPwd, String userNickName, Integer userSex, String userNation, String homePlace, String userBirthday, String userPolitics, String userSchool, String userMajor, String userEnglish, String userPhone, String userEmail, String userQq, String userAddress, String userPhoto, String userRemarks, Set<TbLog> tbLogs, Set<TbResume> tbResumes) {
        this.tbCompany = tbCompany;
        this.userCode = userCode;
        this.userLoginName = userLoginName;
        this.userPwd = userPwd;
        this.userNickName = userNickName;
        this.userSex = userSex;
        this.userNation = userNation;
        this.homePlace = homePlace;
        this.userBirthday = userBirthday;
        this.userPolitics = userPolitics;
        this.userSchool = userSchool;
        this.userMajor = userMajor;
        this.userEnglish = userEnglish;
        this.userPhone = userPhone;
        this.userEmail = userEmail;
        this.userQq = userQq;
        this.userAddress = userAddress;
        this.userPhoto = userPhoto;
        this.userRemarks = userRemarks;
        this.tbLogs = tbLogs;
        this.tbResumes = tbResumes;
    }

   
    // Property accessors
    @Id @GeneratedValue
    
    @Column(name="UserId", unique=true, nullable=false)

    public Integer getUserId() {
        return this.userId;
    }
    
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="CompanyId")

	public TbCompany getTbCompany() {
	    return this.tbCompany;
	}
	
	public void setTbCompany(TbCompany tbCompany) {
	    this.tbCompany = tbCompany;
	}
    
    @Column(name="UserCode", length=20)

    public String getUserCode() {
        return this.userCode;
    }
    
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    
    @Column(name="UserLoginName", nullable=false, length=20)

    public String getUserLoginName() {
        return this.userLoginName;
    }
    
    public void setUserLoginName(String userLoginName) {
        this.userLoginName = userLoginName;
    }
    
    @Column(name="UserPwd", nullable=false, length=20)

    public String getUserPwd() {
        return this.userPwd;
    }
    
    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }
    
    @Column(name="UserNickName", length=20)

    public String getUserNickName() {
        return this.userNickName;
    }
    
    public void setUserNickName(String userNickName) {
        this.userNickName = userNickName;
    }
    
    @Column(name="UserSex")

    public Integer getUserSex() {
        return this.userSex;
    }
    
    public void setUserSex(Integer userSex) {
        this.userSex = userSex;
    }
    
    @Column(name="UserNation", length=20)

    public String getUserNation() {
        return this.userNation;
    }
    
    public void setUserNation(String userNation) {
        this.userNation = userNation;
    }
    
    @Column(name="HomePlace", length=50)

    public String getHomePlace() {
        return this.homePlace;
    }
    
    public void setHomePlace(String homePlace) {
        this.homePlace = homePlace;
    }
    
    @Column(name="UserBirthday", length=20)

    public String getUserBirthday() {
        return this.userBirthday;
    }
    
    public void setUserBirthday(String userBirthday) {
        this.userBirthday = userBirthday;
    }
    
    @Column(name="UserPolitics", length=20)

    public String getUserPolitics() {
        return this.userPolitics;
    }
    
    public void setUserPolitics(String userPolitics) {
        this.userPolitics = userPolitics;
    }
    
    @Column(name="UserSchool", length=50)

    public String getUserSchool() {
        return this.userSchool;
    }
    
    public void setUserSchool(String userSchool) {
        this.userSchool = userSchool;
    }
    
    @Column(name="UserMajor", length=50)

    public String getUserMajor() {
        return this.userMajor;
    }
    
    public void setUserMajor(String userMajor) {
        this.userMajor = userMajor;
    }
    
    @Column(name="UserEnglish", length=20)

    public String getUserEnglish() {
        return this.userEnglish;
    }
    
    public void setUserEnglish(String userEnglish) {
        this.userEnglish = userEnglish;
    }
    
    @Column(name="UserPhone", length=20)

    public String getUserPhone() {
        return this.userPhone;
    }
    
    public void setUserPhone(String userPhone) {
        this.userPhone = userPhone;
    }
    
    @Column(name="UserEmail", length=30)

    public String getUserEmail() {
        return this.userEmail;
    }
    
    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }
    
    @Column(name="UserQQ", length=20)

    public String getUserQq() {
        return this.userQq;
    }
    
    public void setUserQq(String userQq) {
        this.userQq = userQq;
    }
    
    @Column(name="UserAddress", length=50)

    public String getUserAddress() {
        return this.userAddress;
    }
    
    public void setUserAddress(String userAddress) {
        this.userAddress = userAddress;
    }
    
    @Column(name="UserPhoto", length=30)

    public String getUserPhoto() {
        return this.userPhoto;
    }
    
    public void setUserPhoto(String userPhoto) {
        this.userPhoto = userPhoto;
    }
    
    @Column(name="UserRemarks", length=65535)

    public String getUserRemarks() {
        return this.userRemarks;
    }
    
    public void setUserRemarks(String userRemarks) {
        this.userRemarks = userRemarks;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tbUser")

    public Set<TbLog> getTbLogs() {
        return this.tbLogs;
    }
    
    public void setTbLogs(Set<TbLog> tbLogs) {
        this.tbLogs = tbLogs;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tbUser")

    public Set<TbResume> getTbresumes() {
        return this.tbResumes;
    }
    
    public void setTbresumes(Set<TbResume> tbResumes) {
        this.tbResumes = tbResumes;
    }
   
    public UserDTO toDTO(){
    	UserDTO userDTO = new UserDTO();
    	userDTO.setHomePlace(this.getHomePlace());
    	userDTO.setUserAddress(this.getUserAddress());
    	userDTO.setUserBirthday(this.getUserBirthday());
    	userDTO.setUserCode(this.getUserCode());
    	userDTO.setUserEmail(this.getUserEmail());
    	userDTO.setUserId(this.getUserId());
    	userDTO.setUserEnglish(this.getUserEnglish());
    	userDTO.setUserLoginName(this.getUserLoginName());
    	userDTO.setUserMajor(this.getUserMajor());
    	userDTO.setUserNation(this.getUserNation());
    	userDTO.setUserNickName(this.getUserNickName());
    	userDTO.setUserPhone(this.getUserPhone());
    	userDTO.setUserPolitics(this.getUserPolitics());
    	userDTO.setUserPwd(this.getUserPwd());
    	userDTO.setUserQq(this.getUserQq());
    	userDTO.setUserEmail(this.getUserEmail());
    	userDTO.setUserPhoto(this.getUserPhoto());
    	userDTO.setUserSchool(this.getUserSchool());
    	userDTO.setUserRemarks(this.getUserRemarks());
    	userDTO.setUserSex(this.getUserSex());
    	userDTO.setCompanyDTO(this.getTbCompany().toDTO());
    	return userDTO;
    }

}